function Y=odefunction_Amax_paper(t,y)

% ODEFUNCTION_AMAX_PAPER   calculate the concentration of T,D,S,U according to the paper

% t   time span
% y   origin concentration of T,D,S,U
% Y   final concentration of T,D,S,U
%
% KaiA   concentration of KaiA
% m   parameter for adjustment
% kxy0   k_XY^a0 in equation
% kxyA   k_XY^A in equation
% Khalf   K_1/2 in equation


global KaiA m kxy0 kxyA Khalf
m=1;
A=max(0,KaiA-2*m*y(3));
kxy=kxy0+kxyA*A./(Khalf+A);

Y0=[kxy(4,1)*y(4)+kxy(2,1)*y(2)-kxy(1,4)*y(1)-kxy(1,2)*y(1);
   kxy(1,2)*y(1)+kxy(3,2)*y(3)-kxy(2,1)*y(2)-kxy(2,3)*y(2);
   kxy(4,3)*y(4)+kxy(2,3)*y(2)-kxy(3,4)*y(3)-kxy(3,2)*y(3);];

Y=[Y0;
   -Y0(1)-Y0(2)-Y0(3)];